package demo2;

public class Login {
    private String userName = "admin";
    private String password = "123456";
    public void loginInfo(String userName, String password)
                throws UserNameException,PasswordException {
        if (!this.userName.equals(userName)) {
            throw new UserNameException("用户名异常！");
        }
        if (!this.password.equals(password)) {
            throw new PasswordException("密码异常！");
        }
        System.out.println("登陆成功");
    }
    public static void main(String[] args) {
        Login login=new Login();
        try{
            login.loginInfo("admin", "123456");
        }catch(UserNameException e) {
            System.out.println("捕获到了UserNameException");
            e.printStackTrace();
        }catch(PasswordException e) {
            System.out.println("捕获到了PasswordException");
            e.printStackTrace();
        }finally{
            System.out.println("finally执行了...");
        }


    }
}
